<script>
var purchase_num = parent.purchase_num;
$('#formtable').validator({
        submit : function(){
            var badreport_num = $('#badreport_num').val();
            var badreport_reson = $('#badreport_reson').val();
            if(badreport_num && purchase_num < badreport_num) {
                layer.alert("报损数量最大为"+purchase_num);return false;
            }
            if(this.isFormValid()) {
                $.post('', {'badreport_num':badreport_num, 'badreport_reson':badreport_reson}, function (res) {
                    if(res.code == 1) {
                        layer.alert(res.msg);
                        return false
                    }
                    parent.addtogoodsCallBack();
                },'json');

            }
            return false;
        }
});
$('#badreport_num').attr('max', purchase_num);
</script>